<?php
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
require_once('calendar/classes/tc_calendar.php');
?>
<?php 
include "generallibraries/funcs.php";
if(!isset($_REQUEST['page'])){
$list["a.Tile"]="DESC";
$list["a.Timecreate"]="DESC";
$list["e.FullName"]="DESC";
$list["a.IDApproveDoc"]="DESC";
$list["a.TimeApprove"]="DESC";
//$str=$_SESSION['sortn'];
//if($str==''){
$str="a.TimeApprove";
$_SESSION['sortn']=$str;
//}
$_SESSION['sort']=$list;
}else{
	$str=$_SESSION['sortn'];
	$list=$_SESSION['sort'];
}

//$query1  = mysql_query("SELECT IDEmployee,FullName  FROM employee where State!=0 ");
$sql_library="select list_lable.IDLable,list_lable.LableName from list_lable where list_lable.IDEmployee='".$id_employee."'";
$mang_library=mysql_query($sql_library);
$query_de = mysql_query("select department.IDDepartment, department_lang.DepartmentName from department, department_lang where department.IDDepartment = department_lang.IDDepartment and department_lang.LangID='".$lang."'");
$mangkq=array();
while ($row=mysql_fetch_array($query_de)){
	$query11  = mysql_query("SELECT IDEmployee,FullName  FROM employee where State!=0 and IDDepartment='".$row[0]."'");
	$mangone=array();
	while($row1=mysql_fetch_array($query11)){
		$mangone[]=$row1;
	}
	$mangkq[$row[1]]=$mangone;
}
$bien = generalFunctions::xuatds($mangkq,'IDEmployeeSend',$l_all);
	
	if(isset($_REQUEST['TypeDoc']))
		$_SESSION['TypeDoc']=$_REQUEST['TypeDoc'];
	$_SESSION['action'] = "re_reference_approved";
    if(array_key_exists("page",$_GET))
        $page  = $_GET['page'];
    else
        $page = 1;

    $abc = ($page-1)*10;
    
    if (isset($_REQUEST['search'])){
    	$IDEmployeeSend=$_REQUEST['IDEmployeeSend'];
    	$tile=$_REQUEST['titleSearch'];
    	$fromdate=$_REQUEST['date1'];
    	$todate=$_REQUEST['date2'];
    	$search=$_REQUEST['search'];
    	
    	$sql="SELECT a.IDGroupApprove,a.SumMoney,a.IDApproveDoc,e.FullName,a.Tile,DATE_FORMAT(a.Timecreate, '%Y-%m-%d') as Timecreate,a.IDTypeDoc,DATE_FORMAT(a.TimeApprove, '%Y-%m-%d') as TimeApprove
				FROM approvedoc a INNER JOIN employee e ON a.IDEmployee = e.IDEmployee
		    	INNER JOIN list_reference l ON
				a.IDGroupApprove  = l.id_group 
				WHERE l.id_employee  = '$id_employee'   ";
    	if($IDEmployeeSend!='ALL'){
    		$sql .="AND a.IDEmployee='$IDEmployeeSend' ";
    	}
    	if($_SESSION['TypeDoc']==0)
    		$sql .="AND a.IDTypeDoc != 11 AND l.IDLabel  < 1
				AND l.id_status = 1 AND a.Tile LIKE '%$tile%' AND a.Timecreate>'".$fromdate." 00:00:00' AND a.Timecreate<'".$todate." 23:59:59'";
    	else
			$sql .="AND a.IDTypeDoc = ".$_SESSION['TypeDoc']." AND l.IDLabel  < 1
				AND l.id_status = 1 AND a.Tile LIKE '%$tile%' AND a.Timecreate>'".$fromdate." 00:00:00' AND a.Timecreate<'".$todate." 23:59:59'";
		
    	$query= mysql_query($sql." GROUP BY a.IDApproveDoc ORDER BY ".$str." ".$list[$str].",a.Timecreate DESC");
    	$number_of_page = ceil ( mysql_num_rows( $query ) / $rows_per_page ); 
    	
    }
    else {
    	$tile="";
    	$fromdate=date("Y-m-d"); 
    	$todate=date("Y-m-d"); 
    	$IDEmployeeSend="ALL";
    	if($_SESSION['TypeDoc']==0)
    		$sql="SELECT a.IDGroupApprove,a.SumMoney,a.IDApproveDoc,e.FullName,a.Tile,DATE_FORMAT(a.Timecreate, '%Y-%m-%d') as Timecreate,a.IDTypeDoc ,DATE_FORMAT(a.TimeApprove, '%Y-%m-%d') as TimeApprove
				FROM approvedoc a INNER JOIN employee e ON a.IDEmployee = e.IDEmployee
		    	INNER JOIN list_reference l ON
				a.IDGroupApprove  = l.id_group 
				WHERE l.id_employee  = '$id_employee'  
				AND a.IDTypeDoc  != 11 AND l.IDLabel  < 1
				AND l.id_status = 1 GROUP BY a.IDApproveDoc";
    	else
    		$sql="SELECT a.IDGroupApprove,a.SumMoney,a.IDApproveDoc,e.FullName,a.Tile,DATE_FORMAT(a.Timecreate, '%Y-%m-%d') as Timecreate,a.IDTypeDoc ,DATE_FORMAT(a.TimeApprove, '%Y-%m-%d') as TimeApprove
				FROM approvedoc a INNER JOIN employee e ON a.IDEmployee = e.IDEmployee
		    	INNER JOIN list_reference l ON
				a.IDGroupApprove  = l.id_group 
				WHERE l.id_employee  = '$id_employee'  
				AND a.IDTypeDoc  = ".$_SESSION['TypeDoc']." AND l.IDLabel  < 1
				AND l.id_status = 1 GROUP BY a.IDApproveDoc";
    	$query  = mysql_query($sql." ORDER BY ".$str." ".$list[$str].",a.Timecreate DESC");
    	
    	$number_of_page = ceil ( mysql_num_rows( $query ) / $rows_per_page ); 
    }
?>
<script type="text/javascript">
function sort(page,str,co,search,tile,from,to,IdSend)
{
	

	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
											var body = document.getElementById('content');
											body.setAttribute('style','opacity:.5; position:relative;cursor: wait;  ');
											
											var d=document.createElement('div');
											d.setAttribute('style','display: block;visibility: visible; position: absolute;  z-index: 999; top: 0px; left: 0px; width: 105%; height: 105%; text-align: center;  filter: alpha(opacity=5); opacity: 0.5; ');
											
											var image=document.createElement('img');
											image.setAttribute('src','images/loading1.gif');
											image.setAttribute('style','position:absolute; left:0px; top:0px; right:0; bottom:0; margin:auto');
											
											d.appendChild(image);
											
										    body.appendChild(d);	
										    
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("content").innerHTML=xmlhttp.responseText;
										    	document.getElementById('content').setAttribute('style','opacity:1; position:relative;');
										  }
									  }
	xmlhttp.open("GET","ajax/list/sort_re_ref_app.php?page="+page+"&str="+str+"&co="+co+"&search="+encodeURI(search)+"&IDEmployeeSend="+IdSend+"&titleSearch="+tile+"&date1="+from+"&date2="+to,true);
	xmlhttp.send();
}
function addLable(lang,idem,flagaction,search,tile,from,to,idsend)
{
	var newname=document.getElementById("vlNameLabel").value;
	if (newname=="") { alert("Null rồi"); return;}
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("liview").innerHTML=xmlhttp.responseText;
										    	$.ajax({url:"ajax/list/move_menu_left_library.php?lang="+lang+"&idem="+idem,success:function(result){
													//alert(result);
													$("#idlistLi").html(result);
											    }});
										  }
									  }
	xmlhttp.open("GET","ajax/process_li_listvb.php?search="+search+"&IDEmployeeSend="+idsend+"&titleSearch="+tile+"&date1="+from+"&date2="+to+"&flagaction="+flagaction+"&lablename="+newname,true);
	xmlhttp.send();
}
</script>
<style>
<!--
* {margin:0;}
-->
</style>
<link href="css/popup.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	$(document).ready(function(){
		$('#content_menu_expand').hide();
		$(document).click(function() {
			$("#content_menu_expand").hide();
		});
		$('#content_menu_expand').click(function(e) {
			e.stopPropagation();
		});

		$('#menu_expand').click(function() {
			if ($('#content_menu_expand').is(":hidden")) {
				
				var listid="";
				$("input[name='chon']").each(function(){
					if (this.checked) listid = listid+","+this.value;
			    	})
				listid=listid.substr(1);	 
				if (listid=="") { alert("<?php echo $l_nochoose;?>"); return;}
				$('#content_menu_expand').show();
				}
			else {
				$('#content_menu_expand').hide();
			}
			return false;
		});
		$('#close_menu').click(function() {
			$('#content_menu_expand').hide();
			return false;
		});

		$("ul.menu_inside li a").hover(function() {
			$(this).parent().find("ul.subnav").slideDown(0).show();
			$(this).parent().hover(function() {
			}, function(){
				$(this).parent().find("ul.subnav").slideUp(0);
			});
		}).hover(function() {
			$(this).addClass("subhover");
		}, function(){
			$(this).removeClass("subhover");
		});

	});		    
	function onprocessCheckbox(lang,idem,idli,search,tile,from,to,IdSend){
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {
			    //alert(xmlhttp.responseText);
		        document.getElementById("content").innerHTML=xmlhttp.responseText;
		        $.ajax({url:"ajax/list/move_menu_left_library.php?lang="+lang+"&idem="+idem,success:function(result){
					//alert(result);
					$("#idlistLi").html(result);
			    }});
		        $.ajax({url:"ajax/list/move_list_changenumber.php?typeview=3&lang="+lang+"&idem="+idem,success:function(result1){
					$("#slrerefapprove").html(result1);
			    }});
		        bindEventAfterAjax();
		    }
		  }
		var listid="";
		$("input[name='chon']").each(function(){
			if (this.checked) listid = listid+","+this.value;
	    	})
		listid=listid.substr(1);
		hoi= confirm("<?php echo $l_areyousure;?>");
		if (hoi==true) {
			xmlhttp.open("GET","ajax/list/move_re_ref_approved.php?idli="+idli+"&search="+search+"&IDEmployeeSend="+IdSend+"&titleSearch="+tile+"&date1="+from+"&date2="+to+"&content=list-receiver-declined-content&listid=" + listid,true);
			xmlhttp.send();
		}
		
		$('#content_menu_expand').hide();
		}

</script>
<style>
* {font-family:Arial, Helvetica, sans-serif; }
#fade { /*--Transparent background layer--*/
        display: none; /*--hidden by default--*/
        /*background: #000;*/
        position: fixed; left: 0; top: 0;
        width: 100%; height: 100%;
        opacity: .80;
        z-index: 9999;
}
.popup_block{
        display: none; /*--hidden by default--*/
        background: #fff;
        border: 1px solid silver;
        float: left;
        font-size: 1.2em;
        position: fixed;
        top: 50%; left: 50%;
        z-index: 99999;
        /*--CSS3 Box Shadows--*/
        /*--CSS3 Rounded Corners--*/
}
.btn_close {
        float: right;
        margin: 5px 5px 0 0;
		color:white;
		font-weight:bold;
}
/*--Making IE6 Understand Fixed Positioning--*/
*html #fade {
        position: absolute;
}
*html .popup_block {
        position: absolute;
}
.btnupbg {background:#309dcf; border-radius: 3px; color: white; cursor: pointer; font-weight: bold; height: 25px; padding: 0 5px 0 ;border-color: #C4C0B9; border-width: 1px; margin-right:5px}
.btnupbg:hover {background:#686868}
.btnupload {background: -moz-linear-gradient(center top , #63B6DB, #309DCF) repeat;}
</style>
<div class="title"></div>
                    <div class="content_code">
						<div class="approval-right">
							<form action="received.php" method="get">
							<table width="100%" >
								<tr>
									<td>
										<div class="title_content"><?= $l_received_document?> &rarr; <?=$l_reference_document_approved?></div>
											
											<input type="hidden" name="content" value="list-receiver-reference-approved-content" />
											<table  border="1" bordercolor="#C5D1E8" cellpadding="4"  style="border-collapse:collapse"><tr height="40">
												<td align="center" style="vertical-align:middle;width: 120px"><?=$l_created_date?> </td>
												<td align="center" style="height:24px;">
												<?php
												  $myCalendar1 = new tc_calendar("date1", true);
												  $myCalendar1->setIcon("calendar/images/iconCalendar.gif");
												  $d=split('-',$fromdate,3);
												 
												  $myCalendar1->setDate($d[2],$d[1],$d[0]);
												  $myCalendar1->setPath("calendar/");
												  $myCalendar1->setYearInterval(2010, 2015);
												  $myCalendar1->dateAllow('2010-01-01', '2015-12-31');
												  //$myCalendar1->setHeight(350);
												  //$myCalendar1->autoSubmit(true, "form1");
												  //$myCalendar1->setSpecificDate(array("2011-04-01", "2011-04-13", "2011-04-25"), 0, 'month');
												  $myCalendar1->setOnChange("myChanged('test')");
												  //$myCalendar->rtl = true;
												  $myCalendar1->writeScript();
							
												  //echo $myCalendar1->getDate();
												  
												  ?>
												</td >
												
												  <td  align="center" style="height:24px;">
												  <?php
												  $myCalendar2 = new tc_calendar("date2", true);
												  $myCalendar2->setIcon("calendar/images/iconCalendar.gif");
												  $d=split('-',$todate,3);
												 
												  $myCalendar2->setDate($d[2],$d[1],$d[0]);
												  $myCalendar2->setPath("calendar/");
												  $myCalendar2->setYearInterval(2010, 2015);
												  $myCalendar2->dateAllow('2010-01-01', '2015-12-31');
												  //$myCalendar1->setHeight(350);
												  //$myCalendar1->autoSubmit(true, "form1");
												  //$myCalendar1->setSpecificDate(array("2011-04-01", "2011-04-13", "2011-04-25"), 0, 'month');
												  $myCalendar2->setOnChange("myChanged('test')");
												  //$myCalendar->rtl = true;
												  $myCalendar2->writeScript();
												  
												  ?>	
                   							  	<!--  >input type="hidden" name="totime" value="<?php echo $myCalendar2->getDate();?>" />
                   							  	<input type="hidden" name="fromtime" value="<?php echo $myCalendar1->getDate();?>" /-->
																
												</td>												
												</tr>
												<tr height="40">
												<td align="center" style="vertical-align:middle"><?=$l_employee?></td>
												
												
												
												
												
												<td colspan="2" style="padding-left: 3px;">
													<?php echo $bien; ?>
												</td>
												</tr>
												<tr height="40">
												<td align="center" style="vertical-align:middle"><?=$l_title?> </td>
												<td colspan="2" style="padding-left: 3px;padding-right: 3px;">
													<input type="text" name="titleSearch" value="<?=$tile?>" style="width:600px;height:20px;" /></td>
												</tr>
											</table>	
												
																	
												
										</td>
								</tr>
								<?php 
													
											    	$IDEmployeeSend=$_REQUEST['IDEmployeeSend'];
											   
											    	$tile=$_REQUEST['titleSearch'];
											    	echo $tile;
											    	$fromdate=$_REQUEST['date1'];
											    	$todate=$_REQUEST['date2'];
											    	$search=$_REQUEST['search'];
													//page,str,co,search,tile,from,to,IdSend)
								?>
								<tr>
									<td colspan="2" align="left">
										<table width="70%">
										<tr><td align="center">
											<input style="margin:12px 5px 0 0; font-size: 12px;" type="submit" value="<?=$l_search?>" class="btn_choose" name="search" />
											<input style="margin:12px 5px 0 0; font-size: 12px;" type="submit" name="all" value="<?=$l_all?>" class="btn_choose" />
										</td></tr></table>
									</td>
								
								</tr>
								
								<tr>
									<td>										
										<div style=" margin-top:30px" >
											<div style="position:relative; padding-bottom: 5px;">
												<input type="button" class="btnupbg btnupload"  name="Movevb" value="<?php echo $l_move;?>" id="menu_expand" />
											    <div id="content_menu_expand" class="passul">
											        <ul>
											            <li><a href="#?w=350" onclick="popuploadbel(this)" rel="popup_name" class="poplight"><?php echo $l_new_label?></a></li>
											        </ul>
											        <ul id="liview">
											            <?php 
														
															if(mysql_num_rows($mang_library)>0){
																while($row=mysql_fetch_array($mang_library)){
																?>
																<li><a  onclick="onprocessCheckbox('<?php echo $_SESSION['lang']?>','<?php echo $id_employee?>','<?php echo $row[IDLable]?>','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>');" ><?php echo $row[LableName]?></a></li>
																<?php 
																}
															}
														?>
											        </ul>
											    </div>
											</div>
											<div id="popup_name" class="popup_block">
												<span style="background:#424242;color: #FFFFFF; display: block;padding: 5px 0 5px 10px;"><?php echo $l_new_label;?> </span>
											    <table width="100%" style="margin:20px 0">
											    	<tr>
											    	<td width="15%"><b><?php echo $l_name;?></b></td>
											        <td valign="top"><input type="text" id="vlNameLabel" name="vlNameLabel" style="height:23px;width:95%; border:1px solid #ccc" size="35" maxlength="50" value="" /></td>
											        </tr>
											        <tr>
											        	<td></td>
											        	<td>
											        		<div align="center" style="padding-top: 3px;">
											        			<input type="button" class="btnupbg btnupload iclose" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;width:100px;float: right;margin-right: 13px;" value="<?php echo $l_cancel;?>" />
											    				<input type="button" onclick="addLable('<?php echo $_SESSION['lang'];?>','<?php echo $id_employee?>','newlb','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>');" style="float:right; font-family:Arial, Helvetica, sans-serif; font-size:12px;width:100px;float: right;" class="btnupbg btnupload iclose" value="<?php echo $l_create;?>" />
														    </div>
											        	</td>
											        </tr>
											    </table>
											</div>
											<div id='content'>
											<table width="100%" class="table_th" style="height:22px;" cellspacing="0">
												
												<tr class="trtit" style="background-color:#EEE;">
													<td width="3%"><input type="checkbox" name="chonhet" id="chonhet" onclick="clickChonHet(this);"/></td>
													<td width="3%"><?=$l_no?></td>
													<!--td><a onclick="sort(<?=$page?>,'a.IDApproveDoc','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')">ID</a></td-->
										            <td width="20%"><?=$l_document_form?></td>
										            <td width="30%"><a onclick="sort(<?=$page?>,'a.Tile','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')"><?=$l_title?></a></td>
													<td width="10%"><a onclick="sort(<?=$page?>,'e.FullName','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')"><?=$l_writer?></a></td>
													<td width="10%"><a onclick="sort(<?=$page?>,'a.Timecreate','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')"><?=$l_created_date?></a></td>
													<td width="10%"><a onclick="sort(<?=$page?>,'a.TimeApprove','1','<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')"><?=$l_approve_date?></a></td>
									
										        </tr>
												
												
												
												<?php
												
											    $i = 0; 
											    while ($row=mysql_fetch_array($query)){
											    	if ( $i >= $page_start  ) 
													{	
														
												    	if($row['IDTypeDoc']==7)$document = $l_vacation_form;
													    else if($row['IDTypeDoc']==12)$document = $l_assignment_report;
													    else if($row['IDTypeDoc']==13)$document = $l_purchase_order;
													    else if($row['IDTypeDoc']==14)$document = $l_daily_report;
													    else if($row['IDTypeDoc']==15)$document = $l_business_trip_report;
													    else if($row['IDTypeDoc']==16)$document = $l_weekly_report;
													    else if($row['IDTypeDoc']==17)$document = $l_susqence_payment_request;
												    	else if($row['IDTypeDoc']==18)$document = $l_payment_request;
												    	else if($row['IDTypeDoc']==19)$document = $l_purchase_order1;
												?>
													<tr bgcolor="#ffffff" class="highlighter">
														<td><input type="checkbox"  name="chon" value="<?php echo $row[IDGroupApprove];?>" /></td>
														<td width="3%" align="center"><?=($i+1)?></td>
														<!--td width="10%"><a href='received.php?id=<?=$row[IDApproveDoc]?>&type=<?=$row['IDTypeDoc']?>&page=<?=$page?>'><?php echo $row['IDApproveDoc'];?></a></td-->
														<td width="20%"><div  align="left" ><?php echo $document;?></div></td>
														<td width="30%"><div  align="left" ><a href='received&<?=$row['IDApproveDoc']?>&<?=$row['IDTypeDoc']?>&<?=$page?>'><?=$row['Tile']?></a>
															<p style="float:right">
															<?php 
																if($row['IDTypeDoc']==13 || $row['IDTypeDoc']==15 || $row['IDTypeDoc']==17 || $row[IDTypeDoc]==19){
																	if($row[SumMoney]>0){
																		echo " [ ".number_format($row['SumMoney'])." ]";
																	}else{
																		if($row['IDTypeDoc']==15 || $row['IDTypeDoc']==13  || $row[IDTypeDoc]==19){
																			$s1="select sum(buying_document.total) as tongtien from approvedoc,buying_document where approvedoc.IDApproveDoc=buying_document.document_id and approvedoc.IDApproveDoc='".$row[IDApproveDoc]."' GROUP BY approvedoc.IDApproveDoc";
																			$k1=mysql_query($s1);
																			while ($r1=mysql_fetch_array($k1)){
																				if($r1[tongtien]>0){
																					echo " [ ".number_format($r1[tongtien])." ]";
																				}
																			}
																		}else if($row['IDTypeDoc']==17){
																			$s1="select sum(ap_advance.money) as tongtien from approvedoc,ap_advance where approvedoc.IDApproveDoc=ap_advance.document_id and approvedoc.IDApproveDoc='".$row[IDApproveDoc]."' GROUP BY approvedoc.IDApproveDoc";
																			$k1=mysql_query($s1);
																			while ($r1=mysql_fetch_array($k1)){
																				if($r1[tongtien]>0){
																					echo " [ ".number_format($r1[tongtien])." ]";
																				}
																			}
																		}
																	}
																}
															?>
															</p>
														</div></td>
														<td width="15%"><?=$row['FullName']?></td>
														<td width="15%"><?=$row['Timecreate']?></td>
														<td width="15%"><?=$row['TimeApprove']?></td>
													</tr>
												<?php 	}
												
													$i++; 
													
													if ($i >= $page_end) 
													{ 
													break; 
													} 
												}
												
													
												?>
											
											<tr>
													<td colspan="7" class="bt_td_main">
														
													<span style="background:#fff; padding:1px; display: inline-block;">
														
														<?php if ( $number_of_page > 1 ) 
														{ 
															if ($page==1)
																$p=2;
															else if ($page==$number_of_page)
																$p=$number_of_page-1;
															else $p=$page;
															if($page!=1){?>
																<a onclick="sort(1,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')" ><span class='button_next'><?php echo "<<<";?></span> </a>
																<a onclick="sort(<?=($page-1)?>,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')" ><span class='button_next'><?php echo "<<";?></span> </a>
															<?php  }
															else{
																echo "<span class='button_next'><<<</span>"; 
																echo "<span class='button_next'><<</span>";
															}
															for ( $i = $p-1; $i <= $p+1; $i++ ) {	
																	if ($i<=$number_of_page && $i>0)
																	
																		if ($i==$page){
																			echo "<span class='button_next'><b>".$i."</b></span>"; 
																		}else{
																		?>
																			<a onclick="sort(<?=$i?>,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')" ><span class="button_next" style="color: #508e21;">
																			<?php 
																			echo $i;
																			?>
																			</span> </a>
																			<?php 
																		}
																	?>
																
															<?php 
																	}
																
																if($page!=$number_of_page){ ?>
																	<a onclick="sort(<?=($page+1)?>,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')"><span class='button_next'><?php echo ">>";?></span> </a>
																	<a onclick="sort(<?=($number_of_page)?>,'<?=$str?>',0,'<?=$search?>','<?=$tile?>','<?=$fromdate?>','<?=$todate?>','<?=$IDEmployeeSend?>')" ><span class='button_next'><?php echo ">>>";?></span> </a>
																<?php }
																else{
																	echo "<span class='button_next'>>></span> ";
																	echo "<span class='button_next'>>>></span> ";
																}
															}
														
															
															?>
																												
													</span>
													</td>
												</tr>
											</table>
											</div>
										</div>
									</td>
								</tr>
							</table>
							</form>	
						</div>
					</div>